using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.Serialization;
#if SILVERLIGHT
using System.Windows;
#endif

namespace WcfService1.DTO
{
    [DataContract]
    public class CashBankOutDetailDTO : INotifyPropertyChanged
    {
        private CashBankInDTO _CashBankIn;
        private Guid _CashBankInDetailId;
        private DepartemenDTO _Departemen;
        private Decimal _Kredit;
        private Decimal _Debit;
        private CoaDTO _ToAccount;
        private ObservableCollection<PurchaseInvoiceDTO> _PurchaseInvoices;
        private PurchaseInvoiceDTO _PurchaseInvoice;
        private ObservableCollection<CoaDTO> _Coas;
        private int _No;
        private ObservableCollection<DepartemenDTO> _Departemens;
        private SupplierDTO _Supplier;
        private ObservableCollection<SupplierDTO> _Suppliers;
        private string _Description;

#if SILVERLIGHT
        private Visibility _PaymentVisibility;
        private Visibility _NonPaymentVisibility;
#endif
        private bool _IsEnableKredit;
        private bool _IsEnableDebit;
        public CashBankOutDetailDTO()
        {
            IsEnableDebit = true;
            IsEnableKredit = true;
        }

        [DataMember]
        public Guid CashBankInDetailId
        {
            get { return _CashBankInDetailId; }
            set
            {
                _CashBankInDetailId = value;
                RaisePropertyChanged("CashBankInDetailId");
            }
        }


        [DataMember]
        public CashBankInDTO CashBankIn
        {
            get { return _CashBankIn; }
            set
            {
                _CashBankIn = value;
                RaisePropertyChanged("CashBankIn");
            }
        }


        [DataMember]
        public PurchaseInvoiceDTO PurchaseInvoice
        {
            get { return _PurchaseInvoice; }
            set
            {
                _PurchaseInvoice = value;
                RaisePropertyChanged("PurchaseInvoice");
            }
        }


        [DataMember]
        public CoaDTO ToAccount
        {
            get { return _ToAccount; }
            set
            {
                _ToAccount = value;
                RaisePropertyChanged("ToAccount");
            }
        }


        [DataMember]
        public Decimal Debit
        {
            get { return _Debit; }
            set
            {
                _Debit = value;
                RaisePropertyChanged("Debit");
            }
        }


        [DataMember]
        public Decimal Kredit
        {
            get { return _Kredit; }
            set
            {
                _Kredit = value;
                RaisePropertyChanged("Kredit");
            }
        }


        [DataMember]
        public DepartemenDTO Departemen
        {
            get { return _Departemen; }
            set
            {
                _Departemen = value;
                RaisePropertyChanged("Departemen");
            }
        }

        [DataMember]
        public SupplierDTO Supplier
        {
            get { return _Supplier; }
            set
            {
                if (ReferenceEquals(_Supplier, value) || value == null) return;
                _Supplier = value;
                RaisePropertyChanged("Supplier");
            }
        }

        public ObservableCollection<PurchaseInvoiceDTO> PurchaseInvoices
        {
            get { return _PurchaseInvoices; }
            set
            {
                _PurchaseInvoices = value;
                RaisePropertyChanged("PurchaseInvoices");
            }
        }

        public ObservableCollection<CoaDTO> Coas
        {
            get { return _Coas; }
            set
            {
                _Coas = value;
                RaisePropertyChanged("Coas");
            }
        }

        public ObservableCollection<DepartemenDTO> Departemens
        {
            get { return _Departemens; }
            set
            {
                _Departemens = value;
                RaisePropertyChanged("Departemens");
            }
        }

        public ObservableCollection<SupplierDTO> Suppliers
        {
            get { return _Suppliers; }
            set
            {
                _Suppliers = value;
                RaisePropertyChanged("Suppliers");
            }
        }

        [DataMember]
        public String Description
        {
            get { return _Description; }
            set
            {
                _Description = value;
                RaisePropertyChanged("Description");
            }
        }

        public int No
        {
            get { return _No; }
            set
            {
                _No = value;
                RaisePropertyChanged("No");
            }
        }

        public bool IsEnableDebit
        {
            get { return _IsEnableDebit; }
            set 
            {
                _IsEnableDebit = value;
                RaisePropertyChanged("IsEnableDebit");
            }
        }

        public bool IsEnableKredit
        {
            get { return _IsEnableKredit; }
            set
            {
                _IsEnableKredit = value;
                RaisePropertyChanged("IsEnableKredit");
            }
        }

#if SILVERLIGHT
        public Visibility PaymentVisibility
        {
            get { return _PaymentVisibility; }
            set
            {
                if (value == PaymentVisibility) return;
                _PaymentVisibility = value;
                RaisePropertyChanged("PaymentVisibility");
            }
        }

        public Visibility NonPaymentVisibility
        {
            get { return _NonPaymentVisibility; }
            set
            {
                if (value == NonPaymentVisibility) return;
                _NonPaymentVisibility = value;
                RaisePropertyChanged("NonPaymentVisibility");
            }
        }
#endif

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        protected void RaisePropertyChanged(string propertyname)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyname));
        }
    }
}